草庐IT

unit-testing - Golang 模拟 Elastic

全部标签

ruby - Rspec 模拟错误 : wrong number of arguments

我正在尝试使用Rspec对StripeAPI进行stub,但我遇到了一个问题。这是我的代码的样子:Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)这是我遇到的错误:Failure/Error:Stripe::Customer.should_receive(:create).with(any_args).and_raise(Stripe::CardError)ArgumentError:wrongnumberofarguments(0for3..6)

ruby 公案 : test_nil_is_an_object

我最近尝试使用这个工具来提高我的Rails技能:http://github.com/edgecase/ruby_koans但我无法通过一些测试。此外,我不确定我是否正确地做了一些事情,因为目标只是通过测试,有很多方法可以通过它,我可能正在做一些不符合标准的事情。有没有办法确认我做的事情是否正确?具体例子:在about_nil中,deftest_nil_is_an_objectassert_equal__,nil.is_a?(Object),"UnlikeNULLinotherlanguages"end它是告诉我检查第二个子句是否等于一个对象(所以我可以说nil是一个对象)或者只是把as

ruby-on-rails - 模拟 rspec 中的错误/异常(不仅仅是它的类型)

我有一段代码是这样的:defsome_methodbegindo_some_stuffrescueWWW::Mechanize::ResponseCodeError=>eife.response_code.to_i==503handle_the_situationendendend我想测试ife.response_code.to_i==503部分发生了什么。我可以模拟do_some_stuff以抛出正确类型的异常:whatever.should_receive(:do_some_stuff).and_raise(WWW::Mechanize::ResponseCodeError)但是我

camille mumu 模拟器 frida 踩坑记录

1.了解监管机构已经卷到需要监控进程了,为了跟上通报步伐查了下资料,打算浅试一下camille,依据原作的文档初步了解到需要python3、adb、frida、模拟器(木木-已成功、夜神)、root手机,开始逐个尝试,记录一下所遇到的情况。 原作祭上:camille/use.mdatmaster·zhengjim/camille·GitHubhttps://www.cnblogs.com/zhengjim/p/15508738.html2.PythonPython38、pip更新电脑中如果有多个python环境的,记得改好名哦,不然会报错,我是配置了环境变量然后让38的置顶pip如果久没用了也

ruby - 如何使用 lib minitest 或 Test :Unit? 为单元测试着色

我想在我的开发环境中进行单元测试输出颜色。但是,我无法让它在Linux(Debian和Ubuntu)上运行。当我包含以下库时:require'minitest/autorun'require'minitest/unit'require'minitest/pride'我得到:/usr/local/rvm/gems/ruby-1.9.2-p136/gems/minitest-2.3.1/lib/minitest/pride.rb:35:in`':undefinedmethod`output'forMiniTest::Unit:Class(NoMethodError)由代码引起:MiniTe

ruby-on-rails - 使用 Rspec 和 Rack::Test 测试 REST-API 响应

我有点难过。我有以下集成测试:require"spec_helper"describe"/foods",:type=>:apidoincludeRack::Test::Methodslet(:current_user){create_user!}let(:host){"http://www.example.com"}beforedologin(current_user)@food=FactoryGirl.create_list(:food,10,:user=>current_user)endcontext"viewingallfoodsownedbyuser"doit"asJSON"d

ruby - 摩卡模拟进行另一项测试

我一直在关注15TDDstepstocreateaRailsapplication指南-但遇到了一个我似乎无法解决的问题。对于WordsController的功能测试,我有以下代码:classWordsControllerTest在Word类中,我有以下代码:classWord当我运行测试时,我遇到以下错误(为简洁起见缩短):1)Failure:unexpectedinvocation:Word(...).random()satisfiedexpectations:-expectedexactlyonce,alreadyinvokedonce:Word(...).random()我曾尝

ruby - 获取名称错误 : `format' is not allowed as an instance variable name when testing instance variable with rspec

我有以下测试:let(:client){Descat::Client.new}describe'poblacio'doit'shouldsetformatcorrectly'doclient.poblacio('v1','json','dades')expect(client.instance_variable_get(:format)).toeq('json')endend我有以下正在测试的代码:moduleDescatclassClientBASE_URL='http://api.idescat.cat/'definitialize(attributes={})attributes

ruby-on-rails - 使用 Test::Unit 和 Shoulda 设置 Factory Girl

我正在尝试在RubyonRails中使用Test::Unit和Shoulda设置FactoryGirl。我已经安装了gem,在test/factories目录下创建了我的工厂文件,并在test/models目录下创建了我的spec文件。我得到的当前错误是“ArgumentError:没有这样的工厂:测试”,这让我相信没有加载test_factory.rb文件?关于我应该更改什么有任何想法吗?这是我的文件。#test/factories/test_factory.rbFactory.define:testdo|t|t.name'test_spotlight't.label'testspo

ruby - 什么时候使用 MiniTest::Unit::TestCase 与 MiniTest::Spec?

我一直在使用MiniTest学习TDD/BDD。我想弄清楚的是我的代码的哪些部分应该使用MiniTest::Unit::TestCase进行测试,哪些部分应该使用MiniTest::Spec进行测试。我了解单元测试和集成测试之间的区别,我似乎无法从网络上的示例中掌握的是TestCase和Spec是否都是单元测试,或者TestCase是否用于单元测试以及用于集成测试的规范?我是否应该在MiniTest::Unit::TestCase类中保留我的快速单元测试,在MiniTest::Spec期望中保留更长时间的集成测试,后者更经常描述功能?这有关系吗,还是个人喜好问题?